package projectg06.hclinicas;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class PruebaHistClinica extends Prueba {


	public PruebaHistClinica(String nombre, String in, String out) {
		super(nombre, in, out);
	}
	
	private List <RegistroHistoriaClinica> registrosIn;
	private List <RegistroHistoriaClinica> registrosOut;
	private long cantAordenar=0;
	
	public void parseRegistros(){
		registrosIn=parseRegistros(in);
		registrosOut=parseRegistros(out);
		cantAordenar=Long.parseLong(in.substring(0,in.indexOf("\r\n")));
		
	}

	private boolean devolver_igual_cantidad_de_registros() {
		if(registrosIn.size()==registrosOut.size())
			return true;
		 return false;
	}
	
	@Override
	public String toString() {
		StringBuffer sb=new StringBuffer();
		if(registrosIn!=null){
			Iterator<RegistroHistoriaClinica> it= registrosIn.iterator();
			while (it.hasNext()) {
				sb.append(it.next().toString()).append("\r\n");
			}
		}
		return sb.toString();
		
	}
	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args){
		PruebaHistClinica ht=new PruebaHistClinica("Mi prueba","2 Angel Croce\r\n5 Pedro Picapiedras\r\n6 Nadia Nicomedes\r\n7 Pablo Marmol\r\n9 Abel Avila\r\n10 Nicanor Gonzalez\r\n15 Victor Tazo\r\n16 Zoilo Zenon\r\n23 Toribio Tevez\r\n40 Eduardo Sport\r\n55 Alberto Lopez","");
		System.out.println(ht);
	}

	public static List<RegistroHistoriaClinica> parseRegistros(String in){
		if(in==null){
			throw new NullPointerException();
		}
		String[] lineas=in.split("\r\n");
		ArrayList<RegistroHistoriaClinica> historiasClinicas=new ArrayList<RegistroHistoriaClinica>();
		for(int i=0;i<lineas.length;i++){
			if(lineas[i].trim()==""){
				System.out.println("La linea no respeta el formato especificado");
			}else{
				try {
					historiasClinicas.add(RegistroHistoriaClinica.parseRegistro(lineas[i]));
				} catch (Exception e) {
					System.out.println(e.getMessage());
				}
			}
		}
		return historiasClinicas;

	}

	
}
